<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%String path=request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<%@include file="../include/contentheader.jsp"%>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <link rel="stylesheet" type="text/css" href="css/dtree.css"/>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/jquery.blockUI.js"></script> 
	<script type="text/javascript" src="js/dtree.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	
	<!-- DWR -->
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/engine.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/util.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/categoryManager.js"></script>

<script type="text/javascript">
//刷新页面
function refresh(){
	    window.location.href="page/basic/searchResidual.action?FN=<s:property value='FN' />";
	  }
//根据条件查询资产信息
function queryAssetCard(){
 	   var property=document.getElementById("condition");
	   var condition=property.options[property.selectedIndex].value;
		if(condition=="zczt"){
			var propertyBeChoose=document.getElementById("acstatusValue");
			var acstatusValue=propertyBeChoose.options[propertyBeChoose.selectedIndex].value;
			location.href = "queryResidualAssetCard.action?FN=<s:property value='FN' />&condition="+encodeURIComponent($('#condition').val())+"&acstatusValue="+encodeURIComponent($('#acstatusValue').val());   
		}else{
			var conditionValue=document.getElementById("conditionValue").value;
  	    location.href="queryResidualAssetCard.action?FN=<s:property value='FN' />&condition="+encodeURIComponent($('#condition').val())+"&conditionValue="+encodeURIComponent($('#conditionValue').val());   
		}
 		 }
//将数据导出
   function exportTable(){ 
	   if(confirm("确定要导出所有记录吗?")){
          window.location.href="outputResidualAssetCard.action?FN=<s:property value='FN' />";
	   } 
   }
 //状态：残值-物资部部门经办已申请
 function jbAsk(){
	 var allId = document.getElementsByName("checkbox");
     var array = new Array(allId.length);
     var j=0;
     for(var i=0;i<allId.length;i++){
        if(allId[i].checked==true){
             array[j] = allId[i].value;
             j++;
        }
     }
     //如果没有被选中，那么不进行任何操作
     if(j==0){
   	   alert('请选择要进行申请的资产.');
          return;
          }
     var newArray = new Array(j);
     for(var i=0;i<j;i++){
         newArray[i]=array[i];
     }
     if(confirm("确定已经申请资产.")){
         document.getElementById("hiddengoodsacid").value = newArray; 
         document.getElementById("hiddengoodsform").submit();
      }
	 }
 //部门领导退回
 function ldBack(){
	 var allId = document.getElementsByName("checkbox");
     var array = new Array(allId.length);
     var j=0;
     for(var i=0;i<allId.length;i++){
        if(allId[i].checked==true){
             array[j] = allId[i].value;
             j++;
        }
     }
     //如果没有被选中，那么不进行任何操作
     if(j==0){
   	   alert('请选择要进行退回的资产.');
          return;
          }
     var newArray = new Array(j);
     for(var i=0;i<j;i++){
         newArray[i]=array[i];
     }
     if(confirm("确定退回资产.")){
    	 var vRValue = window.showModalDialog("/SSS/page/daily/result.jsp?param=1",null,"dialogWidth=320px;dialogHeight=350px;status=0;scroll=0");
		  	if(vRValue == undefined){
		  	  	vRValue = '';
		  	}
		  	if(vRValue!=null){
			  	document.getElementById("ldBackResult").value=vRValue;
			  	document.getElementById("hiddenldBackacid").value = newArray;
		        document.getElementById("hiddenldBackform").submit();
		  	  }
            }
	 }
	//  状态： 残值-部门领导已审核
 function ldExamine(){
	 var allId = document.getElementsByName("checkbox");
     var array = new Array(allId.length);
     var j=0;
     for(var i=0;i<allId.length;i++){
        if(allId[i].checked==true){
             array[j] = allId[i].value;
             j++;
        }
     }
     //如果没有被选中，那么不进行任何操作
     if(j==0){
   	   alert('请选择待审核的资产.');
          return;
          }
     var newArray = new Array(j);
     for(var i=0;i<j;i++){
         newArray[i]=array[i];
     }
     if(confirm("确定物资已审核 .")){
    	 var vRValue = window.showModalDialog("/SSS/page/daily/result.jsp?param=0",null,"dialogWidth=320px;dialogHeight=350px;status=0;scroll=0");
		  	if(vRValue == undefined){
		  	  	vRValue = '';
		  	}
		  	if(vRValue!=null){
			  	 document.getElementById("ldExamineResult").value=vRValue;
			  	 document.getElementById("hiddenallotacid").value = newArray; 
	             document.getElementById("hiddenallotform").submit();
		  	}
               
      }
	 }
//状态：残值-物资部部门经办已上报
 function jsReport(){
	 var allId = document.getElementsByName("checkbox");
     var array = new Array(allId.length);
     var j=0;
     for(var i=0;i<allId.length;i++){
        if(allId[i].checked==true){
             array[j] = allId[i].value;
             j++;
        }
     }
     //如果没有被选中，那么不进行任何操作
     if(j==0){
   	   alert('请选择要进行上报的资产.');
          return;
          }
     var newArray = new Array(j);
     for(var i=0;i<j;i++){
         newArray[i]=array[i];
     }
     if(confirm("确定已上报资产.")){
				document.getElementById("hiddenacceptacid").value = newArray;
		        document.getElementById("hiddenacceptform").submit();
            }
	 }
 // 状态：残值-部门领导已上报
 function ldReport(){
	 var allId = document.getElementsByName("checkbox");
     var array = new Array(allId.length);
     var j=0;
     for(var i=0;i<allId.length;i++){
        if(allId[i].checked==true){
             array[j] = allId[i].value;
             j++;
        }
     }
     //如果没有被选中，那么不进行任何操作
     if(j==0){
   	   alert('请选择要进行上报的资产.');
          return;
          }
     var newArray = new Array(j);
     for(var i=0;i<j;i++){
         newArray[i]=array[i];
     }
     if(confirm("确定已上报资产.")){
				document.getElementById("hiddenfpacid").value = newArray;
		        document.getElementById("hiddenfpform").submit();
            }
	 }
 //状态：  残值-局领导已审核
 function jldExamine(){
	 var allId = document.getElementsByName("checkbox");
     var array = new Array(allId.length);
     var j=0;
     for(var i=0;i<allId.length;i++){
        if(allId[i].checked==true){
             array[j] = allId[i].value;
             j++;
        }
     }
     //如果没有被选中，那么不进行任何操作
     if(j==0){
   	   alert('请选择要进行审核的资产.');
          return;
          }
     var newArray = new Array(j);
     for(var i=0;i<j;i++){
         newArray[i]=array[i];
     }
     if(confirm("确定已审核资产.")){
    	 var vRValue = window.showModalDialog("/SSS/page/daily/result.jsp?param=0",null,"dialogWidth=320px;dialogHeight=350px;status=0;scroll=0");
		  	if(vRValue == undefined){
		  	  	vRValue = '';
		  	}
		  	if(vRValue!=null){
			  	document.getElementById("jldExamineResult").value=vRValue;
			  	document.getElementById("hiddenjldacid").value = newArray;
		        document.getElementById("hiddenjldform").submit();
		  	}
            }
	 }
 //局领导退回资产
   function jldBack(){
	   var allId = document.getElementsByName("checkbox");
	     var array = new Array(allId.length);
	     var j=0;
	     for(var i=0;i<allId.length;i++){
	        if(allId[i].checked==true){
	             array[j] = allId[i].value;
	             j++;
	        }
	     }
	     //如果没有被选中，那么不进行任何操作
	     if(j==0){
	   	   alert('请选择要进行退回的资产.');
	          return;
	          }
	     var newArray = new Array(j);
	     for(var i=0;i<j;i++){
	         newArray[i]=array[i];
	     }
	     if(confirm("确定退回资产.")){
	    	 var vRValue = window.showModalDialog("/SSS/page/daily/result.jsp?param=1",null,"dialogWidth=320px;dialogHeight=350px;status=0;scroll=0");
			  	if(vRValue == undefined){
			  	  	vRValue = '';
			  	}
			  	if(vRValue!=null){
				  	document.getElementById("jldBackResult").value=vRValue;
				  	document.getElementById("hiddenjldBackacid").value = newArray;
			        document.getElementById("hiddenjldBackform").submit();
			  	  }
	            }
	   }	
//条件选择
	function chose(){
		var property=document.getElementById("condition");
		var conditionValue=document.getElementById("conditionValue");
		var acstatusValue=document.getElementById("acstatusValue");
		if(property.options[property.selectedIndex].value=="zczt"){
			conditionValue.style.display="none";	
			acstatusValue.style.display="inline";
		}else{
			conditionValue.style.display="inline";	
			acstatusValue.style.display="none";
		}
	}
</script>	   	
  </head>
  
  <body>
  <div class="mainContainer">
    <div class="headerTitle">日常信息管理&nbsp;>>&nbsp;资产残值管理</div>
    
       <div class="dtreeDiv" id="managerTree">
			<script type="text/javascript">
				var myTree = document.getElementById("managerTree");
				d = new dTree('d');
				var inner;
				buildTree();
				function buildTree(){
					categoryManager.findAllCategory(function(category) {
						d.add(0, -1, '广元电业局',"searchResidual.action?FN=<s:property value='FN' />");
						for(var i=0; i<category.length; i++){
							var size = category[i].catid.length;
							var url = "queryResidualByCategory.action?FN=<s:property value='FN' />&catid="+category[i].catid;
							if(size == 3){
								d.add(category[i].catid,0,category[i].catname,url);
							}else if(size == 6){
								d.add(category[i].catid,category[i].catid.substr(0,3),category[i].catname,url);
							}else if(size == 10){
								d.add(category[i].catid,category[i].catid.substr(0,6),category[i].catname,url);
							}
						}
						inner = d.toString();
						showBuildTree();
					});
				}
				function showBuildTree() {
					myTree.innerHTML = inner;
				}
			</script>
		</div>
		
     	<div class="dataDivLeftHasTree">
     	
     	<table class="gridTable" border="0" cellspacing="0" cellpadding="0">
			<tr class="operatorAction">
				<td>
	  				<s:if test="accessRight.indexOf('V')!=-1">	
					 <input type="button" style="margin-left:2px;" value="刷新" onclick="refresh();"/>
				    </s:if><s:if test="accessRight.indexOf('P')!=-1">
					<input type="button" style="margin-left:2px;width:70px;" value="经办申请" onclick="jbAsk();" />
					</s:if><s:if test="accessRight.indexOf('R')!=-1">
					 <input type="button" style="margin-left:2px;width:70px;" value="经办上报" onclick="jsReport();" />
					</s:if><s:if test="accessRight.indexOf('A')!=-1">
					<input type="button" style="margin-left:2px;width:70px;" value="领导审核" onclick="ldExamine();" />
					</s:if><s:if test="accessRight.indexOf('B')!=-1">
					<input type="button" style="margin-left:2px;width:70px;" value="领导退回" onclick="ldBack();" />
					</s:if><s:if test="accessRight.indexOf('R')!=-1">
					<input type="button" style="margin-left:2px;width:70px;" value="领导上报" onclick="ldReport();" />
					</s:if><s:if test="accessRight.indexOf('A')!=-1">
					<input type="button" style="margin-left:2px;width:80px;" value="局领导审核" onclick="jldExamine();" />
					</s:if><s:if test="accessRight.indexOf('B')!=-1">
					<input type="button" style="margin-left:2px;width:80px;" value="局领导退回" onclick="jldBack();" />
					</s:if><s:if test="accessRight.indexOf('O')!=-1">
					 <input type="button" style="margin-left:2px;" value="导出" onclick="exportTable();" />
			        </s:if><s:if test="accessRight.indexOf('V')!=-1">
					查询条件：根据&nbsp;&nbsp;<select style="width: 94px;"  id="condition" onblur="chose();"> 
		  					<option selected="selected" value="zclb">资产类别</option>
		  					<option value="zczt">资产状态</option>
		  				</select>
		  				<input style="margin-left:10px;width: 150px" type="text" id="conditionValue" />
		  				<select style="display:none;width: 150px" class="qryTxt" id="acstatusValue">
	  						<option value="750" selected="selected">残值-部门经办已申请</option>
							<option value="751">残值-部门经办已上报</option>
							<option value="752"> 残值-部门领导已审核</option>
							<option value="753">残值-部门领导已上报</option>
							<option value="754">残值-局领导已审核</option>
	  					</select>
		       	        <input type="button" style="margin-left:1px;" value="查询" onclick="queryAssetCard()"/>
			        </s:if>
			
				</td>
			</tr><%-- 功能性操作行 --%>
			<tr>
				<td class="gridData">
				
					<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
					  	<tr class="dataHeader">
					  			<!-- 数据表头 -->
						  <td width="3%"><input id="checkAll" type="checkbox" name="check" value="checkbox" /></td> 
					      <td width="8%">资产卡片编号</td>	
						  <td width="8%">资产名称</td>
						  <td width="12%">所在部门</td>
						  <td width="6%">是否部门公用</td>
						  <td width="6%">使用人</td>
						  <td width="6%">操作人</td>
						  <td width="6%">操作角色</td>
						  <td width="9%">当前资产主状态</td>
						  <td width="9%">资产明细状态</td>
						  <td width="7%">处理结果</td>
						  <td width="6%">处理意见</td>
						  <td width="6%">处理时间</td>
						  <td width="8%">资产类别</td>
						  
						 
						</tr>
								          
								<!-- 数据 -->
						<s:iterator var="ac" value="pagination.dataList">    
						<tr class="dataRow" id="<s:property value='#ac.acid'/>" ondblclick="updateAssetCard('<s:property value="#ac.acid" />')">
						  <td><input name="checkbox" type="checkbox" value="<s:property value='#ac.acid'/>" id="selectItem" /></td>
						  <td><s:property value="#ac.acid.substring(0,13)" /></td>
						  <td><s:property value="#ac.acname"/></td>
						  <td> 
						     <s:property value="#ac.depname"/>
						  </td>
						 
						  <td>
						     <s:if test='#ac.ispublic=="Y"'>是</s:if>
						     <s:else>否</s:else>
						  </td>
						  <td><s:property value="#ac.acuser"/></td>
						  <td></td>
						  <td></td>
						  <td>
						    <s:iterator value="ls">
						       <s:if test="value==#ac.acstatus">
						             <s:property value="desc.substring(0,3)"/>  
						       </s:if>
						   </s:iterator>
						  </td>
						  <td>
						      <s:iterator value="ls">
						       <s:if test="value==#ac.acstatus">
						             <s:property value="desc.substring(4)"/>  
						       </s:if>
						     </s:iterator>
						  </td>
						  <td></td>
						  <td></td>
						  <td></td>
						  <td><s:property value="#ac.category.catname"/></td>
						  
						</tr>
						</s:iterator>
     				</table>
     			</td>
     		</tr>	
			<tr class="dataPager">
				<td>
					<s:property value="pageLink" escapeHtml="false" />
				</td>
			</tr>
     	</table>
    </div>
</div>
		<!--   状态：残值-部门经办已申请 -->
		<form action="updateResidualJBAsk.action" method="post"
			id="hiddengoodsform">
			<input type="hidden" id="hiddengoodsacid" name="idArray" />
			<input type="hidden" id="FN" name="FN"
				value="<s:property value='FN' />" />
		</form>
		<!-- 状态：残值-部门经办已上报 -->
		<form action="updateResidualJBReport.action" method="post"
			id="hiddenacceptform">
			<input type="hidden" id="hiddenacceptacid" name="idArray" />
			<input type="hidden" id="FN" name="FN"
				value="<s:property value='FN' />" />
		</form>
		<!-- 状态： 残值-部门领导已审核 -->
		<form action="updateResidualLDExamine.action" method="post"
			id="hiddenallotform">
			<input type="hidden" id="hiddenallotacid" name="idArray" />
			<input type="hidden" id="ldExamineResult" name="result"/>
			<input type="hidden" id="FN" name="FN"
				value="<s:property value='FN' />" />
		</form>
		<!--状态：残值-部门领导已上报-->
	    <form action="updateResidualLdReport.action" method="post"
		      id="hiddenfpform">
		      <input type="hidden" id="hiddenfpacid" name="idArray" />
		      <input type="hidden" id="FN" name="FN"
			      value="<s:property value='FN' />" />
	   </form>
	<!--状态：   残值-局领导已审核	-->
	   <form action="updateResidualJLDExamine.action" method="post"
		     id="hiddenjldform">
		     <input type="hidden" id="hiddenjldacid" name="idArray" />
		     <input type="hidden" id="jldExamineResult" name="result" value="同意"/>
		     <input type="hidden" id="FN" name="FN"
			      value="<s:property value='FN' />" />
	   </form>
	<!-- 部门领导退回资产 -->
	<form action="updateResidualLDBack.action" method="post"
		id="hiddenldBackform">
		<input type="hidden" id="hiddenldBackacid" name="idArray" />
		<input type="hidden" id="ldBackResult" name="result"/>
		<input type="hidden" id="FN" name="FN"
			value="<s:property value='FN' />" />
	</form>
	<!-- 局领导退回资产 -->
	<form action="updateResidualJLDBack.action" method="post"
		id="hiddenjldBackform">
		<input type="hidden" id="hiddenjldBackacid" name="idArray" />
		<input type="hidden" id="jldBackResult" name="result"/>
		<input type="hidden" id="FN" name="FN"
			value="<s:property value='FN' />" />
	</form>
	</body>
</html>
</html>
